export default  function myCreateStore(reducer,initState){
    let state = initState;
    const getState =()=>(state)
    //设置监听器
    const listens = [];
    const subscibe = (listen)=>{
        listens.push(listen)
    }

    const dispatch=(action)=>{
        state = reducer(state,action);
        listens.forEach(l=>l()) ;
    }

    return{
        getState,
        dispatch,
        subscibe
    }
}